<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>翻牌操作</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    #box{
      position: relative;
      width: 300px;
      height: 300px;
      margin: 50px auto;
      background-color: red;
      transform-style: preserve-3d;
      transition: 1s;
    }
    #box .front{
      position: absolute;
      left: 0;
      right: 0;
      width: 300px;
      height: 300px;
      background-color: lightpink;
    }
    #box .back{
      width: 300px;
      height: 300px;
      transform: rotateY(180deg);
      background-color: lightblue;
    }
  </style>
</head>
<body>
  <div id="box">
    <div class="front"></div>
    <div class="back">王鹤润_闻染</div>
  </div>
  <script>
    //添加移入事件,移入的是整个box,最外层的
    var box = document.getElementById("box");
    //一旦用到事件委派 就用onmouseover/onmosueout这一对
    
    //transform属性 永远相对于它刚开始的
    box.onmouseenter = function (){
      this.style.transform = 'rotateY(180deg)';
      
    }
    box.onmouseleave = function (){
      this.style.transform = 'rotateY(0deg)';
  
    }
  </script>
</body>
</html>